** supplementary materials 2
use "$output/combined_data.dta", clear
drop if child_panel ==0
	
	***************** panel A. check balance of baseline characteristics ****************
	* full sample
reg agemo arm2 if wave==0 , vce(cluster locid)
	est sto h1
	
	reg exp_c arm2 if wave==0 , vce(cluster locid)
	est sto h2
	
	reg male arm2 if wave==0 , vce(cluster locid)
	est sto h3
	
	reg n_target arm2 if wave==0 , vce(cluster locid)
	est sto h4
	
	reg hhsize arm2 if wave==0 , vce(cluster locid)
	est sto h5
	
	reg headmale arm2 if wave==0 , vce(cluster locid)
	est sto h6
	
	reg mumage arm2 if wave==0 , vce(cluster locid)
	est sto h7
	
	reg wi arm2 if wave==0 , vce(cluster locid)
	est sto h8
	
	reg sold arm2 if wave==0 , vce(cluster locid)
	est sto h9
	
	reg livestock arm2 if wave==0 , vce(cluster locid)
	est sto h10
	
	outreg2 [h*] using "$output/in_single3.xls", replace dec(3) stats(coef se) label 

	* only north
	preserve
	keep if north==1
	reg agemo arm2 if wave==0 , vce(cluster locid)
	est sto h1
	
	reg exp_c arm2 if wave==0 , vce(cluster locid)
	est sto h2
	
	reg male arm2 if wave==0 , vce(cluster locid)
	est sto h3
	
	reg n_target arm2 if wave==0 , vce(cluster locid)
	est sto h4
	
	reg hhsize arm2 if wave==0 , vce(cluster locid)
	est sto h5
	
	reg headmale arm2 if wave==0 , vce(cluster locid)
	est sto h6
	
	reg mumage arm2 if wave==0 , vce(cluster locid)
	est sto h7
	
	reg wi arm2 if wave==0 , vce(cluster locid)
	est sto h8
	
	reg sold arm2 if wave==0 , vce(cluster locid)
	est sto h9
	
	reg livestock arm2 if wave==0 , vce(cluster locid)
	est sto h10
	
	outreg2 [h*] using "$output/in_single3.xls", replace dec(3) stats(coef se) label 
	restore
	
	* only poor
	preserve
	keep if poor_r1==1
	reg agemo arm2 if wave==0 , vce(cluster locid)
	est sto h1
	
	reg exp_c arm2 if wave==0 , vce(cluster locid)
	est sto h2
	
	reg male arm2 if wave==0 , vce(cluster locid)
	est sto h3
	
	reg n_target arm2 if wave==0 , vce(cluster locid)
	est sto h4
	
	reg hhsize arm2 if wave==0 , vce(cluster locid)
	est sto h5
	
	reg headmale arm2 if wave==0 , vce(cluster locid)
	est sto h6
	
	reg mumage arm2 if wave==0 , vce(cluster locid)
	est sto h7
	
	reg wi arm2 if wave==0 , vce(cluster locid)
	est sto h8
	
	reg sold arm2 if wave==0 , vce(cluster locid)
	est sto h9
	
	reg livestock arm2 if wave==0 , vce(cluster locid)
	est sto h10
	
	outreg2 [h*] using "$output/in_single3.xls", replace dec(3) stats(coef se) label 
	restore
	
	* only girls
	preserve
	keep if male==0
	reg agemo arm2 if wave==0 , vce(cluster locid)
	est sto h1
	
	reg exp_c arm2 if wave==0 , vce(cluster locid)
	est sto h2
	
	reg male arm2 if wave==0 , vce(cluster locid)
	est sto h3
	
	reg n_target arm2 if wave==0 , vce(cluster locid)
	est sto h4
	
	reg hhsize arm2 if wave==0 , vce(cluster locid)
	est sto h5
	
	reg headmale arm2 if wave==0 , vce(cluster locid)
	est sto h6
	
	reg mumage arm2 if wave==0 , vce(cluster locid)
	est sto h7
	
	reg wi arm2 if wave==0 , vce(cluster locid)
	est sto h8
	
	reg sold arm2 if wave==0 , vce(cluster locid)
	est sto h9
	
	reg livestock arm2 if wave==0 , vce(cluster locid)
	est sto h10
	
	outreg2 [h*] using "$output/in_single3.xls", replace dec(3) stats(coef se) label 
	restore

************ panel B. *****************

	* full sample
	reg agemo arm2 if wave==1 , vce(cluster locid)
	est sto h1
	
	reg male arm2 if wave==1 , vce(cluster locid)
	est sto h2

	reg hhsize arm2 if wave==1 , vce(cluster locid)
	est sto h3
	
	reg headmale arm2 if wave==1 , vce(cluster locid)
	est sto h4
	
	reg mumage arm2 if wave==1 , vce(cluster locid)
	est sto h5
	
	reg wi arm2 if wave==1 , vce(cluster locid)
	est sto h6
	
	reg sold arm2 if wave==1 , vce(cluster locid)
	est sto h7
	
	reg livestock arm2 if wave==1, vce(cluster locid)
	est sto h8
	
	outreg2 [h*] using "$output/in_single3.xls", replace dec(3) stats(coef se) label 

	
	* girls only
	preserve
	keep if male ==0
	reg agemo arm2 if wave==1 , vce(cluster locid)
	est sto h1
	
	reg male arm2 if wave==1 , vce(cluster locid)
	est sto h3

	reg hhsize arm2 if wave==1 , vce(cluster locid)
	est sto h4
	
	reg headmale arm2 if wave==1 , vce(cluster locid)
	est sto h5
	
	reg mumage arm2 if wave==1 , vce(cluster locid)
	est sto h6
	
	reg wi arm2 if wave==1 , vce(cluster locid)
	est sto h7
	
	reg sold arm2 if wave==1 , vce(cluster locid)
	est sto h8
	
	reg livestock arm2 if wave==1, vce(cluster locid)
	est sto h9
	
	outreg2 [h*] using "$output/in_single3.xls", replace dec(3) stats(coef se) label 
	
	
	* poor only
	preserve
	keep if poor_r1 ==1
	reg agemo arm2 if wave==1 , vce(cluster locid)
	est sto h1
	
	reg male arm2 if wave==1 , vce(cluster locid)
	est sto h3

	reg hhsize arm2 if wave==1 , vce(cluster locid)
	est sto h4
	
	reg headmale arm2 if wave==1 , vce(cluster locid)
	est sto h5
	
	reg mumage arm2 if wave==1 , vce(cluster locid)
	est sto h6
	
	reg wi arm2 if wave==1 , vce(cluster locid)
	est sto h7
	
	reg sold arm2 if wave==1 , vce(cluster locid)
	est sto h8
	
	reg livestock arm2 if wave==1, vce(cluster locid)
	est sto h9
	
	outreg2 [h*] using "$output/in_single3.xls", replace dec(3) stats(coef se) label 

	
	* north only
	preserve
	keep if north ==1
	reg agemo arm2 if wave==1 , vce(cluster locid)
	est sto h1
	
	reg male arm2 if wave==1 , vce(cluster locid)
	est sto h3

	reg hhsize arm2 if wave==1 , vce(cluster locid)
	est sto h4
	
	reg headmale arm2 if wave==1 , vce(cluster locid)
	est sto h5
	
	reg mumage arm2 if wave==1 , vce(cluster locid)
	est sto h6
	
	reg wi arm2 if wave==1 , vce(cluster locid)
	est sto h7
	
	reg sold arm2 if wave==1 , vce(cluster locid)
	est sto h8
	
	reg livestock arm2 if wave==1, vce(cluster locid)
	est sto h9
	
	outreg2 [h*] using "$output/in_single3.xls", replace dec(3) stats(coef se) label 
	* check if unbalance in age in month among poor also for full sample at baseline
use "$output/combined_data.dta", clear
	
	reg agemo arm2 if wave==0 & poor_r1==1 , vce(cluster locid)
	
	* check if proportion of private changed between baseline and endline
	
		xi: reg private1 private0 arm20 i.region0 if north1==1 , cluster(locid0) 
	est sto h2
	
		xi: reg private1 private0 arm20 i.region0 if primary1==1 , cluster(locid0) 
	est sto h2

******* UPTAKE: SUPPLEMENTARY MATERIALS 3 AND DATA REPORTED IN PAPER

	use "$output/combined_data.dta", clear
	drop if child_panel ==0
 
	est sto clear
	xi:reg sf agemo exp_c male poor_r1 i.north if wave ==1 & arm2==1, vce(cluster locid) 
	est sto h1
	
	xi:reg sf agemo exp_c male poor_r1 i.north zmaths_r1 zlit_r1  if wave ==1 & arm2==1, vce(cluster locid) 
	est sto h2
	
	xi:reg sf agemo exp_c male poor_r1 i.north zmaths_r1 zlit_r1 i.arm if wave ==1 & arm2==1, vce(cluster locid) 
	est sto h3
	
	xi:reg sf agemo exp_c male poor_r1 i.north  zmaths_r1 zlit_r1  primary grade_r1 private haz_r1 sick ///
		headage mumage hhsize sold wi if wave ==1 & arm2==1, vce(cluster locid) 
	est sto h4
	
	outreg2 [h*] using "$output/in_single3.xls", replace dec(3) stats(coef se) label 
	
	**** ROBUSTNESS
	
	gen inter=0 if arm2!=. & wave!=. 
		replace inter=1 if wave==1 & arm2==1
	
	teffects ipw (zmaths) (child_panel inter wave north#arm2, probit)

	
	leebounds zmaths inter , select(north)
	
	vce(cluster locid)

	*** data on uptake reported in the paper
	
	su sf if wave==1 & arm2==1 
	*61%
	su sf if wave ==1 & arm2 ==1 & private ==0 & primary==1
	* 82.2
	
	* gen mean uptake by community
	bys locid: egen mean_uptake = mean(sf) if wave ==1 & arm2 ==1 & private ==0 & primary==1
	su mean_uptake
	histogram mean_uptake
	
	. tab mean_uptake

	/*
mean_uptake	Freq.	Percent	Cum.
			
0	25	2.63	2.63
.0909091	11	1.16	3.79
.1	10	1.05	4.84
.2666667	15	1.58	6.41
.3333333	18	1.89	8.31
.4444444	9	0.95	9.25
.4615385	13	1.37	10.62
.4827586	29	3.05	13.67
.5	10	1.05	14.72
.5263158	19	2.00	16.72
.5714286	14	1.47	18.19
.7307692	26	2.73	20.93
.75	12	1.26	22.19
.7777778	9	0.95	23.13
.7843137	51	5.36	28.50
.7857143	28	2.94	31.44
.7894737	19	2.00	33.44
.8461538	26	2.73	36.17
.85	20	2.10	38.28
.8888889	18	1.89	40.17
.9047619	21	2.21	42.38
.90625	32	3.36	45.74
.9166667	24	2.52	48.26
.9333333	15	1.58	49.84
.9375	16	1.68	51.52
.9411765	17	1.79	53.31
.9615385	26	2.73	56.05
.9642857	28	2.94	58.99
.96875	32	3.36	62.36
1	358	37.64	100.00
			
Total	951	100.00
*/

* Supplementary materials 5

use "$output/combined_data.dta", clear

	*** The analysis sample is defined in the following way:
	*1. Keep only children of target-age at baseline (this done in the dataset file)
	*2. Drop children that were already in secondary at baseline or had completed primary and were out of school and were never eligible (this done in the dataset file)
	*3. Drop children that did not stay in the panel (4%)
	
	drop if child_panel ==0
	
	* girls / boys
	estpost tabstat maths lit if wave==0 & arm2==0 & male ==1, statistics(mean sd) columns(statistics) 
	
	esttab using "$output/IN_estimates3.csv", replace cells(mean(fmt(2)) sd(par)) nostar unstack obslast ///
	nonote nomtitle nonumber label title(YC - Round 2) 
	
	estpost tabstat maths lit if wave==0 & arm2==1 & male ==1, statistics(mean sd) columns(statistics) 
	
	esttab using "$output/IN_estimates3.csv", replace cells(mean(fmt(2)) sd(par)) nostar unstack obslast ///
	nonote nomtitle nonumber label title(YC - Round 2) 
	
	est sto clear
	preserve
	keep if male ==1
	reg maths arm2 agemo if wave==0 , vce(cluster locid)
	est sto h1
	
	reg lit arm2 agemo if wave==0 , vce(cluster locid)
	est sto h2
	
	outreg2 [h*] using "$output/in_single3.xls", replace dec(3) stats(coef se) label 
	restore
	
	* poor / non poor
	estpost tabstat maths lit if wave==1 & arm2==0 & poor_r1 ==0, statistics(mean sd) columns(statistics) 
	
	esttab using "$output/IN_estimates3.csv", replace cells(mean(fmt(2)) sd(par)) nostar unstack obslast ///
	nonote nomtitle nonumber label title(YC - Round 2) 
	
	estpost tabstat maths lit if wave==1 & arm2==1 & poor_r1 ==0, statistics(mean sd) columns(statistics) 
	
	esttab using "$output/IN_estimates3.csv", replace cells(mean(fmt(2)) sd(par)) nostar unstack obslast ///
	nonote nomtitle nonumber label title(YC - Round 2) 
	
	est sto clear
	preserve
	keep if poor_r1 ==0
	
	reg maths arm2 agemo if wave==0 , vce(cluster locid)
	est sto h1
	
	reg lit arm2 agemo if wave==0 , vce(cluster locid)
	est sto h2
	
	outreg2 [h*] using "$output/in_single3.xls", replace dec(3) stats(coef se) label 
	restore
	
	* north/south
	estpost tabstat maths lit if wave==1 & arm2==0 & north ==0, statistics(mean sd) columns(statistics) 
	
	esttab using "$output/IN_estimates3.csv", replace cells(mean(fmt(2)) sd(par)) nostar unstack obslast ///
	nonote nomtitle nonumber label title(YC - Round 2) 
	
	estpost tabstat maths lit if wave==1 & arm2==1 & north ==0, statistics(mean sd) columns(statistics) 
	
	esttab using "$output/IN_estimates3.csv", replace cells(mean(fmt(2)) sd(par)) nostar unstack obslast ///
	nonote nomtitle nonumber label title(YC - Round 2) 
	
	est sto clear
	preserve
	keep if north==0
	
	reg maths arm2 agemo if wave==0 , vce(cluster locid)
	est sto h1
	
	reg lit arm2 agemo if wave==0 , vce(cluster locid)
	est sto h2
	
	outreg2 [h*] using "$output/in_single3.xls", replace dec(3) stats(coef se) label 
	restore
	
	
	****** Appendix SM 8: differences by treatment arm (GSFP vs HGSF)
	
	est sto clear
	xi: reg zmaths1 zmaths0 i.arm0 i.region0 , cluster(locid0) 
		test  _Iarm0_1 -  _Iarm0_2 =0
		outreg2 using "$output/in_single3.xls", replace dec(3) stats(coef se) label addstat(test,`r(p)') ///
			keep (_Iarm0_1 -  _Iarm0_2) 
	
	
	xi: reg zlit1 zlit0 i.arm0 i.region0 , cluster(locid0) 
		test  _Iarm0_1 -  _Iarm0_2 =0
		outreg2 using "$output/in_single3.xls", append dec(3) stats(coef se) label addstat(test,`r(p)') ///
			keep (_Iarm0_1 -  _Iarm0_2) 
			
	xi: reg learn_ind1 learn_ind0 i.arm0 i.region0 , cluster(locid0) 
		test  _Iarm0_1 -  _Iarm0_2 =0
		outreg2 using "$output/in_single3.xls", append dec(3) stats(coef se) label addstat(test,`r(p)') ///
			keep (_Iarm0_1 -  _Iarm0_2) 
	
			
*** Appendix SM9 descriptive statistics
use "$output/combined_data.dta", clear
drop if child_panel ==0

	iebaltab enrol days_attend grade digit raven zdigit zraven haz baz   if wave==0  ,  grpvar(arm2 ) save("$output/in_single3.xls") replace
	iebaltab enrol days_attend grade digit raven zdigit zraven haz baz   if wave==1  ,  grpvar(arm2 ) save("$output/in_single3.xls") replace
	
	* ROBUSTNESS (in APPENDIX SM10): DAY OF TESTING EFFECTS

	est sto clear
	
	xi: reg nobrk1 nobrk0 arm20 i.region0, cluster(locid0) 
	est sto h1
	
	xi: reg num_meal1 agemo1 arm20 i.region0 , cluster(locid0) 
	est sto h2
	
	xi: reg dd91 agemo1 arm20 i.region0 , cluster(locid0) 
	est sto h3
	
	outreg2 [h*] using "$output/in_single3.xls", replace dec(3) stats(coef se) label sortvar(arm2) 
	
	* gender  
	est sto clear
	xi: reg nobrk1 nobrk0 arm20 i.region0 if male1==0, cluster(locid0) 
	est sto h1
	
	xi: reg nobrk1 nobrk0 arm20 i.region0 if male1==1, cluster(locid0) 
	est sto h2
	
	xi: reg num_meal1 agemo1 arm20 i.region0 if male1==0, cluster(locid0) 
	est sto h3
	
	xi: reg num_meal1 agemo1 arm20 i.region0 if male1==1, cluster(locid0) 
	est sto h4
	
	xi: reg dd91 agemo1 arm20 i.region0 if male1==0, cluster(locid0) 
	est sto h5
	
	xi: reg dd91 agemo1 arm20 i.region0 if male1==1, cluster(locid0) 
	est sto h6
	
	outreg2 [h*] using "$output/in_single3.xls", replace dec(3) stats(coef se) label sortvar(arm2) 
	restore
	
	* poor only 
	est sto clear
	
	xi: reg nobrk1 nobrk0 arm20 i.region0 if poor_r10 ==1, cluster(locid0) 
	est sto h1
	
	xi: reg nobrk1 nobrk0 arm20 i.region0 if poor_r10 ==0, cluster(locid0) 
	est sto h2
	
	xi: reg num_meal1 agemo1 arm20 i.region0 if poor_r10 ==1, cluster(locid0) 
	est sto h3
	
	xi: reg num_meal1 agemo1 arm20 i.region0 if poor_r10 ==0, cluster(locid0) 
	est sto h4
	
	xi: reg dd91 agemo1 arm20 i.region0 if poor_r10 ==1, cluster(locid0) 
	est sto h5
	
	xi: reg dd91 agemo1 arm20 i.region0 if poor_r10 ==0, cluster(locid0) 
	est sto h6
	
	outreg2 [h*] using "$output/in_single3.xls", replace dec(3) stats(coef se) label sortvar(arm2) 
	
	
	* North only 
	est sto clear
	 
	xi: reg nobrk1 nobrk0 arm20 i.region0 if north1 ==1, cluster(locid0) 
	est sto h1
	
	xi: reg nobrk1 nobrk0 arm20 i.region0 if north1 ==0, cluster(locid0) 
	est sto h2
	
	xi: reg num_meal1 agemo1 arm20 i.region0 if north1 ==1, cluster(locid0) 
	est sto h3
	
	xi: reg num_meal1 agemo1 arm20 i.region0 if north1 ==0 , cluster(locid0) 
	est sto h4
	
	xi: reg dd91 agemo1 arm20 i.region0 if north1 ==1, cluster(locid0) 
	est sto h5
	
	xi: reg dd91 agemo1 arm20 i.region0 if north1 ==0, cluster(locid0) 
	est sto h6
	
	outreg2 [h*] using "$output/in_single3.xls", replace dec(3) stats(coef se) label sortvar(arm2) 
	restore
	
